﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using WAD.WEB.AppCode;
using WAD.DAL;

namespace WAD.WEB.Client2.Ajax
{
    /// <summary>
    /// 统计
    /// </summary>
    public partial class Statistics : AjaxBase
    {
        public override void AjaxMethodDispatch(String identity)
        {
            switch (identity)
            {
                case "getcount": this.GetCount(); break;
                case "getviewsharedlist": this.GetViewSharedList(); break;
                case "getviewadvertlist": this.GetViewAdvertList(); break;
                case "getclicksharedlist": this.GetClickSharedList(); break;
                case "getclickadvertlist": this.GetClickAdvertList(); break;
            }
        }
        /// <summary>
        /// 获取默认的频道列表
        /// </summary>
        [QD.Web.Ajax.AjaxMethod]
        public void GetCount()
        {
            IsLogin();

            int sharedId = Parse.Int("shared_id", 0);
            int advertId = Parse.Int("advert_id", 0);

            Success(DaoStatistics.GetCount(sharedId, advertId, UserId));
        }


        /// <summary>
        /// 获取分享的阅读情况
        /// </summary>
        [QD.Web.Ajax.AjaxMethod]
        public void GetViewSharedList()
        {
            IsLogin();

            int pageIndex = Parse.Int("page_index", 1);
            int sharedId = Parse.Int("shared_id", 0);
            int day = Parse.Int("day", 0);

            if (sharedId == 0)
            {
                //获取用户分享汇总点击量
                Success(DaoSharedClick.GetListByUser(pageIndex, 20, UserId, day));
            }
            else
            {
                //获取用户分享汇总点击量
                Success(DaoSharedClick.GetListByShared(pageIndex, 20, sharedId, day));
            }
        }

        /// <summary>
        /// 获取分享的阅读情况
        /// </summary>
        [QD.Web.Ajax.AjaxMethod]
        public void GetViewAdvertList()
        {
            IsLogin();

            int pageIndex = Parse.Int("page_index", 1);
            int advertId = Parse.Int("advert_id", 0);
            int day = Parse.Int("day", 0);

            if (advertId == 0)
            {
                //获取用户分享汇总点击量
                Success(DaoSharedClick.GetListByUser(pageIndex, 20, UserId, day));
            }
            else
            {
                //获取用户分享汇总点击量
                Success(DaoSharedClick.GetListByAdvert(pageIndex, 20, advertId, day));
            }
        }


        /// <summary>
        /// 获取分享的点击情况
        /// </summary>
        [QD.Web.Ajax.AjaxMethod]
        public void GetClickSharedList()
        {
            IsLogin();

            int pageIndex = Parse.Int("page_index", 1);
            int sharedId = Parse.Int("shared_id", 0);
            int day = Parse.Int("day", 0);

            if (sharedId == 0)
            {
                //获取用户分享汇总点击量
                Success(DaoAdvertClick.GetListByUser(pageIndex, 20, UserId, day));
            }
            else
            {
                //获取用户分享汇总点击量
                Success(DaoAdvertClick.GetListByShared(pageIndex, 20, sharedId, day));
            }
        }


        /// <summary>
        /// 获取分享的阅读情况
        /// </summary>
        [QD.Web.Ajax.AjaxMethod]
        public void GetClickAdvertList()
        {
            IsLogin();

            int pageIndex = Parse.Int("page_index", 1);
            int advertId = Parse.Int("advert_id", 0);
            int day = Parse.Int("day", 0);

            if (advertId == 0)
            {
                //获取用户分享汇总点击量
                Success(DaoAdvertClick.GetListByUser(pageIndex, 20, UserId, day));
            }
            else
            {
                //获取用户分享汇总点击量
                Success(DaoAdvertClick.GetListByAdvert(pageIndex, 20, advertId, day));
            }
        }
    }
}